package test.com;

import au.com.bytecode.opencsv.CSVReader;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @author lk
 * @date 2020/6/26 0026 15:25
 * @description: 读取csv文件中的测试用例
 */
public class ReadData {
    private static String FILE_PATH;

    ArrayList<String[]> parametervals = new ArrayList<>();
    public ReadData(String filepath) {
        FILE_PATH = filepath;
    }

    public String getFilePath() {
        return FILE_PATH;
    }

    public ArrayList<String[]> readcsvData(int num) throws IOException {
        CSVReader reader = new CSVReader(new FileReader(FILE_PATH));
        String[] nextLine;
        while ((nextLine = reader.readNext()) != null) {
            String[] s = new String[num];
            for (int i = 0; i < num; i++) {
                s[i] = nextLine[i];
            }
            parametervals.add(s);
        }
        reader.close();
        return parametervals;
    }

}
